import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace ManagerApi {
  /** 飞手信息 */
  export interface Manager {
    id: number; // 编号
    name?: string; // 飞手姓名
    status?: number; // 状态
    idNumber: string; // 身份证
    certNumber: string; // 证书编号
    certCreated: string; // 证书创建时间
    certExp: string; // 证书过期时间
    certAuthority: string; // 发证机构
  }
}

/** 查询飞手分页 */
export function getManagerPage(params: PageParam) {
  return requestClient.get<PageResult<ManagerApi.Manager>>(
    '/pilot/manager/page',
    { params },
  );
}

/** 查询飞手详情 */
export function getManager(id: number) {
  return requestClient.get<ManagerApi.Manager>(`/pilot/manager/get?id=${id}`);
}

/** 新增飞手 */
export function createManager(data: ManagerApi.Manager) {
  return requestClient.post('/pilot/manager/create', data);
}

/** 修改飞手 */
export function updateManager(data: ManagerApi.Manager) {
  return requestClient.put('/pilot/manager/update', data);
}

/** 删除飞手 */
export function deleteManager(id: number) {
  return requestClient.delete(`/pilot/manager/delete?id=${id}`);
}

/** 批量删除飞手 */
export function deleteManagerListByIds(ids: number[]) {
  return requestClient.delete(
    `/pilot/manager/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出飞手 */
export function exportManager(params: any) {
  return requestClient.download('/pilot/manager/export-excel', params);
}
